import { getClient } from '~~/utils/env'

//手机号注册
export function register(params: any) {
    return $request.post({
        url: '/login/register',
        params
    })
}

//邮箱注册
export function emailRegister(params: any) {
    return $request.post({
        url: '/login/email/register',
        params
    })
}

//向微信请求code的链接
export function getWxCodeUrl() {
    return $request.get({
        url: '/login/scanCodeUrl',
        params: {
            url: location.href
        }
    })
}

export function wxLogin(params: any) {
    return $request.post({ url: '/login/scanLogin', params })
}

//忘记密码
export function forgotPassword(params: Record<string, any>) {
    return $request.post({ url: '/login/forgotPassword', params })
}

export function checkTicket(params?: any) {
    return $request.post({
        url: '/login/ticket',
        params
    })
}

//向微信请求code的链接
export function getWxCode(params?: any) {
    return $request.get({
        url: '/login/qrcode',
        params
    })
}

// 手机密码登录
export function Passwordlogin(params: any) {
    return $request.post({
        url: '/login/accountLogin',
        params: { ...params, terminal: getClient() }
    })
}

// 手机验证码登录
export function Codelogin(params: any) {
    return $request.post({
        url: '/login/mobileLogin',
        params: { ...params, terminal: getClient() }
    })
}

// 邮箱登录
export function emailLogin(params: any) {
    return $request.post({
        url: '/login/emailLogin',
        params: { ...params, terminal: getClient() }
    })
}

//发送邮箱验证码
export function sendEmailCode(params: any) {
    return $request.post({ url: '/index/sendEmail', params })
}

// 登出
export function logout() {
    return $request.post({ url: '/login/logout' })
}

// 注册绑定分销
export function bindRegisterInvite(params: any) {
    return $request.post({ url: '/share/register/invite', params })
}

//获取图形验证码
export function captcha() {
    return $request.get({ url: '/login/captcha' })
}
